package com.payment.ktb.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.model.MessageNoticeEntity;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by admin on 2017/9/22.
 */

public class AdapterActiviteMsg extends BaseAdapter {

    private Context mContext;
    private List<MessageNoticeEntity> listdatas;

    public AdapterActiviteMsg(Context mContext, List<MessageNoticeEntity> listdatas) {
        this.mContext = mContext;
        this.listdatas = listdatas;
    }

    public AdapterActiviteMsg() {
    }

    @Override
    public int getCount() {
        return listdatas.size();
    }

    @Override
    public Object getItem(int i) {
        return listdatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = View.inflate(mContext, R.layout.adapter_activitemsg_item,null);
            viewHolder.tv_activemsg_noticeTime = (TextView) view.findViewById(R.id.tv_activemsg_noticeTime);
            viewHolder.tv_activemsg_noticeTitle = (TextView) view.findViewById(R.id.tv_activemsg_noticeTitle);
            viewHolder.tv_activemsg_noticeContent = (TextView) view.findViewById(R.id.tv_activemsg_noticeContent);
            viewHolder.iv_activemsg_noticeIcon = (ImageView) view.findViewById(R.id.iv_activemsg_noticeIcon);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tv_activemsg_noticeTime.setText(listdatas.get(i).getNoticeTime());
        viewHolder.tv_activemsg_noticeTitle.setText(listdatas.get(i).getNoticeTitle());
        viewHolder.tv_activemsg_noticeContent.setText(listdatas.get(i).getNoticeContent());
        Picasso.with(mContext).load(listdatas.get(i).getNoticeIcon()).fit().into(viewHolder.iv_activemsg_noticeIcon);

        return view;
    }


    class ViewHolder {

        TextView tv_activemsg_noticeTime;
        TextView tv_activemsg_noticeTitle;
        ImageView iv_activemsg_noticeIcon;
        TextView tv_activemsg_noticeContent;

    }

}
